import 'package:fijkplayer/fijkplayer.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
// import 'HttpDemo.dart';

class CartPage extends StatefulWidget {
  const CartPage({Key? key = const Key('any_key')}) : super(key: key);

  @override
  _CartPageState createState() => _CartPageState();
}

class _CartPageState extends State<CartPage> {
  final FijkPlayer player = FijkPlayer();

  @override
  void initState() {
    super.initState();
    player.setDataSource(
        "https://av.alarabiya.net/alarabiapublish/alhadath.smil/playlist.m3u8",
        // this._list.map["播放地址"],
        // "https://m3u8.361lu.com/us.php?key=aUl5cUR0d2NYY0VqUnFWdUt3bytONUZQQVZ0RXZxVi9qT0hVWmJUbkhGb1M3dlJxZ0FQRGVqemd4Z3kxTTNJOERoYzlBMFJERnB2NU9MTVZYVlFvR2kzMnhCZFgya293WEdURHl1U0VFcVBsNG9iVGdKMnRFRWpRZGFrczB4RFJzd1JtSkRGcVJDclgxNngwUVd5WlNMbE1KSzFaS05Cbzg0bjdValdVVDF3PQ==&hash=e0f7d8db67530138110db99c6199ec71b431822c8109902f30a7379102f8fd955f6816a12e4043787a1c543113c5e69efae9e31c35cc5ef669a3e3f2a763c421&vid=4689",
        autoPlay: true);
  }

  @override
  void dispose() {
    super.dispose();
    player.release();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        appBar: AppBar(
          leading: new IconButton(
            // tooltip: '返回',
            icon: const Icon(Icons.arrow_back),
            onPressed: () {
              Navigator.of(context).pop();
              //_nextPage(-1);
            },
          ),
          title: Text('返回'),
          backgroundColor: Colors.blue,
        ),
        body: Container(
          height: 300,
          // width: 200,
          child: FijkView(
            player: player,
            fit: FijkFit.cover,
            color: Colors.black,

          ),
        ),
      ),
    );
  }
}